home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 653 b | 34 lines | [TEXT/CWIE] |
- // AlignedBlock.h
-
- #ifndef AlignedBlock_h
- #define AlignedBlock_h
-
- #ifndef Integers_h
- #include "Integers.h"
- #endif
-
- template < uint32 size >
- class AlignedBlock
- {
- typedef uint32 Unit; // Set this to the hardest-to-align type
-
- private:
- Unit space[ (size + sizeof(Unit) - 1) / sizeof(Unit) ];
-
- public:
- void *operator[]( uint32 position )
- {
- return reinterpret_cast<uint8 *>( space ) + position;
- }
-
- const void *operator[]( uint32 position ) const
- {
- return reinterpret_cast<const uint8 *>( space ) + position;
- }
-
- operator const void *() const { return space; }
- operator void *() { return space; }
- };
-
- #endif
-